#ifndef _OSRM_ROUTER_
#define _OSRM_ROUTER_

#include <QNetworkAccessManager>
#include <QPointF>
#include <QList>
#include <QDomDocument>

class OSRMRouter: public QObject
{
    Q_OBJECT

public:
    OSRMRouter(QString host = "127.0.0.1", QString port = "5000");
    ~OSRMRouter();

    void findRoute(QPointF start, QPointF dest);
    QList<QPointF>& currentRouteRef();

    enum
    {
        NO_ERROR = 0,
        FAILD_RETRIEVE,
        INVALID_DATA_FORMAT
    };

signals:
    void routingFinished(int error);

private slots:
    void readXml(QNetworkReply* reply);

private:
    int parseXml(QDomDocument* document);
    bool parseStringWithPoints(QString pointsStr);

private:
    QString host_;
    QString port_;
    QNetworkAccessManager* networkRouteAccess_;
    QList<QPointF> currentRoute_;

};

#endif
